package com.gpframework.common.core.domain.entity;

import com.gpframework.common.annotation.Excel;
import com.gpframework.common.annotation.Excel.ColumnType;
import com.gpframework.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.sql.Time;

/**
 * 角色表 sys_role
 *
 * @Author gpframework
 */
public class SysRole extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 角色ID
     */
    @Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
    private Long roleId;

    /**
     * 角色名称
     */
    @Excel(name = "角色名称")
    private String roleName;

    /**
     * 角色权限
     */
    @Excel(name = "角色权限")
    private String roleKey;

    /**
     * 角色排序
     */
    @Excel(name = "角色排序")
    private String roleSort;

    /**
     * 数据范围（1：所有数据权限；2：自定义数据权限；3：本部门数据权限；4：本部门及以下数据权限）
     */
    @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
    private String dataScope;

    /**
     * 菜单树选择项是否关联显示（ 0：父子不互相关联显示 1：父子互相关联显示）
     */
    private boolean menuCheckStrictly;

    /**
     * 部门树选择项是否关联显示（0：父子不互相关联显示 1：父子互相关联显示 ）
     */
    private boolean deptCheckStrictly;

    /**
     * 是否可修改异常（0：否 1：是 ）
     */
    private String isException;

    /**
     * 是否可打印（0：否 1：是 ）
     */
    private String isPrint;

    /**
     * 是否可发货（0：否 1：是 ）
     */
    private String isDestination;

    /**
     * 是否可中转扫一扫（0：否 1：是 ）
     */
    private String isTransfer;

    /**
     * 是否可撤回（0：否 1：是 ）
     */
    private String isWithdraw;

    /**
     * 是否可发车（0：否 1：是 ）
     */
    private String isDeparture;

    /**
     * 是否可上传物流单（0：否 1：是 ）
     */
    private String isLogisticsOrder;

    /**
     * 是否可上传自提图片（0：否 1：是 ）
     */
    private String isSelfPick;

    /**
     * 是否可截图（0：否 1：是 ）
     */
    private String isScreenshot;

    /**
     * 是否自动弹出上传（0：否 1：是 ）
     */
    private String isAutoUpload;

    /**
     * 可查询天数
     */
    private Integer queryDays;

    /**
     * 可查询开始时间
     */
    private Time queryStartTime;

    /**
     * 可查询结束时间
     */
    private Time queryEndTime;

    /**
     * 角色状态（0正常 1停用）
     */
    @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;

    /**
     * 用户是否存在此角色标识 默认不存在
     */
    private boolean flag = false;

    /**
     * 菜单组
     */
    private Long[] menuIds;

    /**
     * 部门组（数据权限）
     */
    private Long[] deptIds;

    public SysRole() {

    }

    public SysRole(Long roleId) {
        this.roleId = roleId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public boolean isAdmin() {
        return isAdmin(this.roleId);
    }

    public static boolean isAdmin(Long roleId) {
        return roleId != null && 1L == roleId;
    }

    @NotBlank(message = "角色名称不能为空")
    @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    @NotBlank(message = "权限字符不能为空")
    @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    @NotBlank(message = "显示顺序不能为空")
    public String getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(String roleSort) {
        this.roleSort = roleSort;
    }

    public String getDataScope() {
        return dataScope;
    }

    public void setDataScope(String dataScope) {
        this.dataScope = dataScope;
    }

    public boolean isMenuCheckStrictly() {
        return menuCheckStrictly;
    }

    public void setMenuCheckStrictly(boolean menuCheckStrictly) {
        this.menuCheckStrictly = menuCheckStrictly;
    }

    public boolean isDeptCheckStrictly() {
        return deptCheckStrictly;
    }

    public void setDeptCheckStrictly(boolean deptCheckStrictly) {
        this.deptCheckStrictly = deptCheckStrictly;
    }

    public String getIsException() {
        return isException;
    }

    public void setIsException(String isException) {
        this.isException = isException;
    }

    public String getIsPrint() {
        return isPrint;
    }

    public void setIsPrint(String isPrint) {
        this.isPrint = isPrint;
    }

    public String getIsDestination() {
        return isDestination;
    }

    public void setIsDestination(String isDestination) {
        this.isDestination = isDestination;
    }

    public String getIsTransfer() {
        return isTransfer;
    }

    public void setIsTransfer(String isTransfer) {
        this.isTransfer = isTransfer;
    }

    public String getIsWithdraw() {
        return isWithdraw;
    }

    public void setIsWithdraw(String isWithdraw) {
        this.isWithdraw = isWithdraw;
    }

    public String getIsDeparture() {
        return isDeparture;
    }

    public void setIsDeparture(String isDeparture) {
        this.isDeparture = isDeparture;
    }

    public String getIsLogisticsOrder() {
        return isLogisticsOrder;
    }

    public void setIsLogisticsOrder(String isLogisticsOrder) {
        this.isLogisticsOrder = isLogisticsOrder;
    }

    public String getIsSelfPick() {
        return isSelfPick;
    }

    public void setIsSelfPick(String isSelfPick) {
        this.isSelfPick = isSelfPick;
    }

    public String getIsScreenshot() {
        return isScreenshot;
    }

    public void setIsScreenshot(String isScreenshot) {
        this.isScreenshot = isScreenshot;
    }

    public String getIsAutoUpload() {
        return isAutoUpload;
    }

    public void setIsAutoUpload(String isAutoUpload) {
        this.isAutoUpload = isAutoUpload;
    }

    public Integer getQueryDays() {
        return queryDays;
    }

    public void setQueryDays(Integer queryDays) {
        this.queryDays = queryDays;
    }

    public Time getQueryStartTime() {
        return queryStartTime;
    }

    public void setQueryStartTime(Time queryStartTime) {
        this.queryStartTime = queryStartTime;
    }

    public Time getQueryEndTime() {
        return queryEndTime;
    }

    public void setQueryEndTime(Time queryEndTime) {
        this.queryEndTime = queryEndTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Long[] getMenuIds() {
        return menuIds;
    }

    public void setMenuIds(Long[] menuIds) {
        this.menuIds = menuIds;
    }

    public Long[] getDeptIds() {
        return deptIds;
    }

    public void setDeptIds(Long[] deptIds) {
        this.deptIds = deptIds;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("roleId", getRoleId())
                .append("roleName", getRoleName())
                .append("roleKey", getRoleKey())
                .append("roleSort", getRoleSort())
                .append("dataScope", getDataScope())
                .append("menuCheckStrictly", isMenuCheckStrictly())
                .append("deptCheckStrictly", isDeptCheckStrictly())
                .append("isException", getIsException())
                .append("isPrint", getIsPrint())
                .append("isDestination", getIsDestination())
                .append("isTransfer", getIsTransfer())
                .append("isWithdraw", getIsWithdraw())
                .append("isDeparture", getIsDeparture())
                .append("status", getStatus())
                .append("delFlag", getDelFlag())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}
